﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace ProjetoFinal
{
    // FAZER RESTART
    // COLISÃO E PONTO COM AS FRUTAS

    public class MyGame
    {
        public MyGame(KeyboardState nowKeybord, KeyboardState oldKeyboard)
        {

        }

        Leaf leaf;
        Monckey monckey;
        CollisionManager collisionManager;
        int vida;
        bool lostLife = false;

        public void Initialize()
        {
            leaf = new Leaf(5, new Rectangle(360, 677, 305, 91));
            monckey = new Monckey(new Rectangle(360,544, 200,196), new Vector2(5,5));
            collisionManager = new CollisionManager();
            vida = 3;
        }

        public void LoadContent(ContentManager content)
        {
            leaf.LoadContent(content);
            monckey.LoadContent(content);
        }


        public void Update(KeyboardState nowKeybord, KeyboardState oldKeyboard)
        {
            
            monckey.Move();
            leaf.Move(nowKeybord, oldKeyboard);
            collisionManager.Collision(leaf, monckey);

            if (vida > 0)
            {
                monckey.BackToPosition(vida, ref lostLife);
                leaf.BackToPosition(ref lostLife);
            }


        }

        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Begin();
            leaf.Draw(spriteBatch);
            monckey.Draw(spriteBatch);
            spriteBatch.End();
        }



    }
}
